<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>我的草稿</title>
<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../../css/common.css" />
<style>
.draftBox .draftInfo {
		padding:0 1.2rem 0 0.8rem;
		background: #fff;
		min-height: 6.3rem;
}
.draftBox .tit{
	font-size: 0.7rem;
	color: #010101;
	padding-left: 0.4rem;
	line-height: 22px;
}
.draftBox .dateBox{
	font-size: 12px;
	color: #ADADAD;
	padding-left: 0.4rem;
}
.draftBox .dateBox .time{
	padding-left: 0.4rem;
}
.aui-ellipsis-3 {
  display: -webkit-box;
  overflow: hidden;
  text-overflow: ellipsis;
  word-wrap: break-word;
  word-break: break-all;
  white-space: normal !important;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.media{
	width: 4.2rem;
	height: 4.2rem;
}
.media > img{
	width: 4.2rem;
	height: 100%;
}
.inner{
	padding: 1rem 0;
}
.notData{
	/*height: 100%;*/
}
</style>
</head>
<body>
<div class="section">
	<div class="notData aui-hide aui-flex-row aui-flex-middle">
		<img src="../../image/notdata/15.png" class="notImg" alt="">
		<div class="color-ad aui-font-size-14 txt">还没有草稿</div>
	</div>
	<div class="draftBox">
		<div id="data_html">

		</div>
		<script type="text/x-dot-template" id="data_tpl">
			{{for(var i in it){}}
					<div class="draftInfo comFlexItem">
						<div class="comCheckbox checkbox aui-margin-r-5" data-ariId="{{=it[i].article_id}}" tapmode onclick="checkedItem(this)"></div>
						<div class="inner aui-border-b comFlexItem flex-auto " data-ariId="{{=it[i].article_id}}" tapmode onclick="openPush(this)">
							<div class="media"><img src="{{=it[i].article_cover}}" alt=""></div>
							<div class="flex-auto">
								<div class="tit aui-ellipsis-3">{{=it[i].article_content}}</div>
								<div class="dateBox"><span class="date">{{=it[i].article_addtime}}</div>
							</div>
						</div>
					</div>
				{{}}}
			</script>
	</div>
</div>

</div>
</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript">
var postData = {};
var currentPage = 1;
var pageSize = 50;
var draft = 1;
var isLoading = false;
var loadFlag = true;
apiready = function(){
	api.parseTapmode();
	// 监听到达底部
	api.addEventListener({
		name:'scrolltobottom',
		extra:{
			threshold: 0
		}
	}, function(ret, err){
		if(isLoading) return;
		if(loadFlag){
			getDataList();
		}
	});
	// 监听删除成功刷新
	api.addEventListener({
	    name: 'delSuccessEvent'
	}, function(ret, err){
	    if( ret ){
			currentPage = 1;
			getDataList();
	    }
	});

	getDataList()
};
function openPush(el){
	var id = $$(el).data('ariId');
	api.openWin({
		name: 'publish_finish_win',
		url: '../publish/publish_finish_win.html',
		animation: {
			type: 'movein',
			subType:"from_bottom"
		},
		slidBackEnabled: false,
		reload: true,
		pageParam: {
			type: 'edit',
			article_id: id
		}
	});
}
function getDataList(){
	postData = {
		userid: getUserId(),
		pageNo: currentPage,
		pageSize: pageSize,
		draft: draft
	}
	isLoading = true;
	showProgress();
	api.ajax({
	    url: BASE_URL + 'App/Article/myArticleList',
	    method: 'post',
	    data: {
	        values: postData,
	    }
	},function(ret, err){
	    if (ret) {
	        if(ret.code == 1 && ret.data.length > 0){
						$$('.notData').addClass('aui-hide');
						var tpl = $$('#data_tpl').html();
						var tempFn = doT.template(tpl);
						$$('#data_html').html(tempFn(ret.data))
						currentPage++;
						api.parseTapmode();
						if(ret.data.length < pageSize){
								loadFlag = false;
						}
					}else{
						if(currentPage == 1){
								$$('#data_html').html('');
								$$('.notData').removeClass('aui-hide');
						}
					}
			}
			isLoading = false;
			hideProgress();
	});

}
function checkedItem(el){
	$$(el).toggleClass('checked');
	delId()
}
function delId(){
	var idArr = '';
	$$('.comCheckbox').each(function () {
		if($$(this).hasClass('checked')){
			if(idArr){
				idArr = idArr + ',' + $$(this).data('ariId');
			}else{
				idArr = $$(this).data('ariId');
			}
		}
		api.sendEvent({
				name: 'idArrEvent',
				extra: {
						idArr: idArr
				}
		});
	})
}
</script>
</html>
